package com.bbva.kyfb.kyfbjpatlsb.dominiotlsb;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Embeddable;

import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.roo.addon.entity.RooIdentifier;

import flexjson.JSONDeserializer;
import flexjson.JSONSerializer;

/**
 * The Class TtlsbeooPK.
 */
@Embeddable
@Configurable
@RooIdentifier(dbManaged = true)
public final class TtlsbeooPK implements java.io.Serializable {
	
	
	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	public String toString ()
	{
		return "Clase: "+ getCodCampoord()+" Tipo: "+ getCodTipord();
	}

	/**
	 * To json.
	 *
	 * @return the string
	 */
	public String toJson() {
        return new JSONSerializer().exclude("*.class").serialize(this);
    }

	/**
	 * From json to ttlsbeoo pk.
	 *
	 * @param json the json
	 * @return the ttlsbeoo pk
	 */
	public static TtlsbeooPK fromJsonToTtlsbeooPK(String json) {
        return new JSONDeserializer<TtlsbeooPK>().use(null, TtlsbeooPK.class).deserialize(json);
    }

	/**
	 * To json array.
	 *
	 * @param collection the collection
	 * @return the string
	 */
	public static String toJsonArray(Collection<TtlsbeooPK> collection) {
        return new JSONSerializer().exclude("*.class").serialize(collection);
    }

	/**
	 * From json array to ttlsbeoo p ks.
	 *
	 * @param json the json
	 * @return the collection
	 */
	public static Collection<TtlsbeooPK> fromJsonArrayToTtlsbeooPKs(String json) {
        return new JSONDeserializer<List<TtlsbeooPK>>().use(null, ArrayList.class).use("values", TtlsbeooPK.class).deserialize(json);
    }

	/** The cod tipord. */
	@Column(name = "COD_TIPORD", columnDefinition = "CHAR", nullable = false, length = 4)
    private String codTipord;

	/** The cod campoord. */
	@Column(name = "COD_CAMPOORD", columnDefinition = "CHAR", nullable = false, length = 3)
    private String codCampoord;

	/**
	 * Instantiates a new ttlsbeoo pk.
	 *
	 * @param codTipord the cod tipord
	 * @param codCampoord the cod campoord
	 */
	public TtlsbeooPK(String codTipord, String codCampoord) {
        super();
        this.codTipord = codTipord;
        this.codCampoord = codCampoord;
    }

	/**
	 * Instantiates a new ttlsbeoo pk.
	 */
	public TtlsbeooPK() {
        super();
    }

	/**
	 * Gets the cod tipord.
	 *
	 * @return the cod tipord
	 */
	public String getCodTipord() {
        return this.codTipord;
    }

	/**
	 * Gets the cod campoord.
	 *
	 * @return the cod campoord
	 */
	public String getCodCampoord() {
        return this.codCampoord;
    }

	/* (non-Javadoc)
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	public boolean equals(Object obj) {
        if (this == obj) return true;
        if (obj == null) return false;
        if (!(obj instanceof TtlsbeooPK)) return false;
        TtlsbeooPK other = (TtlsbeooPK) obj;
        if (codTipord == null) {
            if (other.codTipord != null) return false;
        } else if (!codTipord.equals(other.codTipord)) return false;
        if (codCampoord == null) {
            if (other.codCampoord != null) return false;
        } else if (!codCampoord.equals(other.codCampoord)) return false;
        return true;
    }

	/* (non-Javadoc)
	 * @see java.lang.Object#hashCode()
	 */
	public int hashCode() {
        final int prime = 31;
        int result = 17;
        result = prime * result + (codTipord == null ? 0 : codTipord.hashCode());
        result = prime * result + (codCampoord == null ? 0 : codCampoord.hashCode());
        return result;
    }

	/** The Constant serialVersionUID. */
	private static final long serialVersionUID = 1L;
}
